﻿using Jhong.FunMVC.Test.Model;
using System;

namespace Jhong.FunMVC.Test
{
    public class DefaultController : Controller
    {
        public void MyIndex1()
        {
        }

        [HttpGet]
        public void MyIndex2(Person model)
        {
        }

        //        [HttpPost]
        public ActionResult MyIndex3()
        {
            var model2 = new Person() { Name = "小明", ID = 1, Age = 10, Sex = "男" };
            return Json(model2);
        }

        [HttpPost]
        public void MyIndex3(int id, string name, int age, string sex)
        {
            var x = Request.Forms;
        }

        public ActionResult C()
        {
            return Content("你好");
        }

        public ActionResult CV()
        {
            ViewData["v1"] = "小蝶惊鸿";
            return View();
        }

        public ActionResult MV()
        {
            this.GetEx();
            var person = new Person()
            {
                ID = 1,
                Name = "小蝶惊鸿",
                Sex = "男",
                Age = 23
            };
            ViewData["person"] = person;
            return View();
        }

        private void GetEx()
        {
            try
            {
                int.Parse("exit");
            }
            catch 
            {
                throw;
            }
        }

        public override void OnException(ExceptionContext context)
        {
            base.OnException(context);
        }


        public ActionResult TestArg(int id,string name,int age,string sex)
        {
            return View();
        }

        public ActionResult TestArg2(Person p)
        {
            return null;
        }

    }
}